TOP 30 Java Interview Coding Tasks by Matthew Urban
Author:Matthew Urban [Urban, Matthew]
Language: eng
Format: epub
ISBN: 9788365477088
Publisher: net-boss
Published: 2018-07-02T23:00:00+00:00
Listing 15.2 – All possible permutations of characters in String object (iterative).
public class StringUtils { public static List<String> permutation(String text){ List<String> permutations = new ArrayList<>(); List<String> result = new ArrayList<>(); result.add(text.substring(0,1)); int length = text.length(); for (int i=1; i < length; i++) { permutations.clear(); for (String perm : result) { permutations.addAll(addCharacter(text.charAt(i), perm)); } result.clear(); result.addAll(permutations); } return result; } private static Set<String> addCharacter(Character c, String text) { Set<String> set = new HashSet<>(); int length = text.length(); for (int i=0; i<= length; i++) { set.add(text.substring(0, i) + c + text.substring(i, length)); } return set; } }
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(22239)
Hello! Python by Anthony Briggs(21443)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(19977)
Dependency Injection in .NET by Mark Seemann(19412)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(19129)
Kotlin in Action by Dmitry Jemerov(19023)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(18602)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(17436)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(16958)
Grails in Action by Glen Smith Peter Ledbrook(16575)
Sass and Compass in Action by Wynn Netherland Nathan Weizenbaum Chris Eppstein Brandon Mathis(14130)
Secrets of the JavaScript Ninja by John Resig & Bear Bibeault(12115)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(10846)
A Developer's Guide to Building Resilient Cloud Applications with Azure by Hamida Rebai Trabelsi(10592)
Jquery UI in Action : Master the concepts Of Jquery UI: A Step By Step Approach by ANMOL GOYAL(9963)
Hit Refresh by Satya Nadella(9109)
The Kubernetes Operator Framework Book by Michael Dame(8535)
Exploring Deepfakes by Bryan Lyon and Matt Tora(8359)
Robo-Advisor with Python by Aki Ranin(8305)